define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'writergoods/index' + location.search,
                    // add_url: 'writergoods/add',
                    edit_url: 'writergoods/edit',
                    // del_url: 'writergoods/del',
                    // multi_url: 'writergoods/multi',
                    // import_url: 'writergoods/import',
                    table: 'writer_goods',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        {field: 'username', title: __('用户名称'), operate: false},
                        // {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        
                        {field: 'type_name', title: __('类型'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'title', title: __('Title'), operate: 'LIKE'},
                        // {field: 'row_type', title: __('Row_type')},
                        {field: 'price', title: __('Price'), operate:'BETWEEN'},
                        {field: 'word_count', title: __('Word_count'), operate: 'LIKE'},
                        {field: 'start_shooting', title: __('Start_shooting'), operate: 'LIKE'},
                    
                        // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'status', title: __('审核状态')},
                       {field: 'm.status', title: __('审核状态'), searchList: {"0":__('申请中'),"1":__('审核通过'),"2":__('审核未通过')}, formatter: Table.api.formatter.normal},
                        // {field: 'sh_time', title: __('Sh_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                       {field: 'create_time', title: __('申请时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'refuse_msg', title: __('Refuse_msg'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'buy_num', title: __('Buy_num')},
                        // {field: 'type', title: __('Type'), searchList: {"11":__('Type 11')}, formatter: Table.api.formatter.normal},
                       
                        // {field: 'rank', title: __('Rank')},
                        // {field: 'rank_num', title: __('Rank_num')},
                        // {field: 'look_num', title: __('Look_num')},
                        // {field: 'word_count_label', title: __('Word_count_label'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'weigh', title: __('Weigh'), operate: false},
                        // {field: 'type_class', title: __('Type_class'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
